import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/public/views/public_webview/view.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';

class LoginProtocol extends StatefulWidget {
  final String prxRemind;

  LoginProtocol({super.key, this.prxRemind = "登录"});

  @override
  State<LoginProtocol> createState() => _LoginProtocolState();
}

class _LoginProtocolState extends State<LoginProtocol> {
  TapGestureRecognizer _serverRecognizer = TapGestureRecognizer();
  TapGestureRecognizer _privacyRecognizer = TapGestureRecognizer();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _serverRecognizer.onTap = () {
      Get.to(HLWebViewPage(
        url: "https://resource.miguanex.com/Resource/PrivacyAgreement/UserServiceAgreement.html",
        title: "服务协议",
      ));
    };

    _privacyRecognizer.onTap = () {
      Get.to(HLWebViewPage(
        url: "https://resource.miguanex.com/Resource/PrivacyAgreement/MiguanApp.html",
        title: "隐私协议",
      ));
    };
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 30),
      child: Text.rich(TextSpan(children: [
        TextSpan(
            text: "${widget.prxRemind}即代表同意",
            style: TextStyle(
              fontSize: MGFont.textFont3,
              color: MGColors.text3Color,
            )),
        TextSpan(
            text: "《蜜罐服务协议》",
            style: TextStyle(
              fontSize: MGFont.textFont3,
              color: MGColors.text2Color,
            ),
            recognizer: _serverRecognizer),
        TextSpan(
            text: "和",
            style: TextStyle(
              fontSize: MGFont.textFont3,
              color: MGColors.text3Color,
            )),
        TextSpan(
            text: "《隐私协议》",
            style: TextStyle(
              fontSize: MGFont.textFont3,
              color: MGColors.text2Color,
            ),
            recognizer: _privacyRecognizer)
      ])),
    );
  }
}
